package com.hkts.management.unattended.order.service.serviceimpl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hkts.management.unattended.order.entity.HktsOrderInfo;
import com.hkts.management.unattended.order.mapper.HktsOrderInfoMapper;
import com.hkts.management.unattended.order.service.IHktsOrderInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author yck
 * @since 2021-09-16
 */
@Service
public class HktsOrderInfoServiceImpl extends ServiceImpl<HktsOrderInfoMapper, HktsOrderInfo> implements IHktsOrderInfoService {


    @Autowired
    private HktsOrderInfoMapper hktsOrderInfoMapper;

    @Override
    public IPage<HktsOrderInfo> selectPage(Page<HktsOrderInfo> page, HktsOrderInfo hktsOrderInfo) {
        QueryWrapper<HktsOrderInfo> query = Wrappers.query();
        return hktsOrderInfoMapper.selectPage(page, query);
    }


    @Override
    public List<HktsOrderInfo> selectList() {
        QueryWrapper<HktsOrderInfo> query = Wrappers.query();
        return hktsOrderInfoMapper.selectList(query);
    }
    public HktsOrderInfo getLastOrderInfo(){
        QueryWrapper<HktsOrderInfo> query = Wrappers.query();
        query.lambda().orderByDesc(HktsOrderInfo::getUpdateTime);
        query.last("limit 1");
        List<HktsOrderInfo> hktsOrderInfo=hktsOrderInfoMapper.selectList(query);
        return hktsOrderInfo.get(0);
    }


}
